import React from "react";
import store from "../../redux/store";
import {increment,decrement,incrementasync} from "../../redux/actions"
import "./count.less";

// 后台管理的home页
export default class Count extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      theme: "dark",
      current: "1",
    };
  }

  add = () => {
    // 调用actions中的方法
    store.dispatch(increment(1))
  };

  
  jf = () => {
    store.dispatch(decrement(1))
  };
  asyncAdd=()=>{
    store.dispatch(incrementasync(1,5000))
  }

  render() {
    return (
      <div>
        <h1>{store.getState()}</h1>
        <div className="item">
          <button onClick={this.add}>+1</button>
          <button onClick={this.jf}>-1</button>
          <button onClick={this.asyncAdd}>异步+1</button>
        </div>
      </div>
    );
  }
}
